Public Class UICommands

    Public Class CommandInfo
        Sub New(Command As String, Discription As String, Callback As tester)
            Me.Command = Command
            Me.Description = Description
            Me.Callback = Callback
        End Sub
        Public Command As String
        Public Description As String
        Public Callback As tester
    End Class

    Public Delegate Sub tester(command As String, arguments As IList(Of String))
    Public CommandTable As New Dictionary(Of String, CommandInfo)()

    Public Sub New()
        CommandTable.Add("/help", New CommandInfo("/help", "Show Command helps", Sub(command As String, arguments As IList(Of String))
                                                                                 End Sub))
        CommandTable.Add("/cls", New CommandInfo("/cls", "Clear Screen", Sub(command As String, arguments As IList(Of String))
                                                                         End Sub))
        CommandTable.Add("/echo", New CommandInfo("/echo", "Display Messages", Sub(command As String, arguments As IList(Of String))
                                                                               End Sub))
        CommandTable.Add("/fps", New CommandInfo("/fps", "FPS Counter", Sub(command As String, arguments As IList(Of String))
                                                                        End Sub))
    End Sub

    Public Sub RegisterCommand(Command As String, Description As String, Callback As tester)
        Dim lowerCommand As String = Command.ToLower()
        If CommandTable.ContainsKey(lowerCommand) Then
            Throw New InvalidOperationException([String].Format("Command ""{0}"" is already registered.", Command))
        End If
        CommandTable.Add(lowerCommand, New CommandInfo(Command, Description, Callback))
    End Sub

    Public Sub UnregisterCommand(Command As String)
        Dim lowerCommand As String = Command.ToLower()
        If Not commandTable.ContainsKey(lowerCommand) Then
            Throw New InvalidOperationException([String].Format("Command ""{0}"" is not registered.", Command))
        End If
        commandTable.Remove(Command)
    End Sub

End Class
